using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Xml;
using MbUnit.Framework;
using XmlObjects;

namespace XmlImportUnitTests
{
	[TestFixture]
	public class UnitTest1
	{

		[Test]
		public void TestHydrator()
		{
			XmlDocument document = new XmlDocument();
			document.Load("MyClass.xml");
			Hydrator<MyClass> hydrator = new Hydrator<MyClass>();
			MyClass myClass = hydrator.GetValueLocal(document.SelectSingleNode("myClass"));
			Assert.AreEqual(myClass.AttributeOne, "FooBar");
			Assert.AreEqual(myClass.ElementOne, "FooBar");
			Assert.AreEqual(myClass.Nide, "FooBar");
		}

		[Test]
		public void TestHydratorFailsOnNotSpecified()
		{
			List<string> list = new List<string>();
			Type listType = list.GetType();
			Type genericType = listType.GetGenericTypeDefinition();
			Console.WriteLine(genericType.FullName);
			IEnumerable<string> enumerable = null;

			Console.WriteLine(GetType().GetProperty("Foobar").PropertyType.GetGenericTypeDefinition().FullName);
			
			string[] strings = new string[1];
			Assert.AreEqual(strings.GetType(), typeof(string[]));
		}

		public IList<string> Foobar
		{
			get
			{
				return null;
			}
		}

		

		[Test]
		public void TestAbleToSelectLocalAttribute()
		{
			XmlDocument document = new XmlDocument();
			XmlNode node = document.CreateElement("g");
			node.Attributes.Append(document.CreateAttribute("coolbar"));

			Assert.IsNotNull(node.SelectSingleNode("@coolbar"));
		}
		
		[Test]
		public void TestOne()
		{
			XmlDocument document = new XmlDocument();
			XmlElement element = document.CreateElement("name");
			document.AppendChild(element);
			MyClass myClass = new MyClass();
			Hydrator<MyClass> hydrator = new Hydrator<MyClass>();

			
		}

		[SetUp]
		public void SetUp()
		{

		}

		[TearDown]
		public void TearDown()
		{

		}

		[Serializeable("myClass")]
		public class MyClass
		{
			private string attributeOne;
			private string elementOne;
			private string nide;
			private IList<string> warefore;

//			[Property("doolfar/jdnordberg")]
//			public IList<string> Warefore
//			{
//				get { return warefore; }
//				set { warefore = value; }
//			}

			[Attrib("attributeOne")]
			public string AttributeOne
			{
				get { return attributeOne; }
				set { attributeOne = value; }
			}

			[Property("elementOne")]
			public string ElementOne
			{
				get { return elementOne; }
				set { elementOne = value; }
			}

			[Property("coolbar/Nide")]
			public string Nide
			{
				get { return nide; }
				set { nide = value; }
			}

			
		}
	}
}